﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="MyList.aspx.cs" Inherits="jnxc.Web.stock.MyList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .fitem {
        float:left;}
            .fitem label {
            width:30px;
            line-height:24px;
            }
    </style>

    <script src="../Script/sitedata.js"></script>
    <script src="../Script/city.js"></script>
     <script type="text/javascript">
         var provinceName;
         var cityName;
         var arrCity;
         var areaName;
         var arrArea;
         $(function () {
             InitSelect();
             InitGird();
            
         });
         function InitSelect()
         {
             loadName();
             $.ajax({
                 type: "post",
                 dataType: "json",
                 url: "../admin/getinfo.ashx?action=level",
                 success: function aa(data) {
                     $('#level').val(data[0].level);                     
                     if (data[0].level == 3) {
                         provinceName = data[0].province;
                         $('#uprovince').combobox('setValue', data[0].province);
                         $("#dprovince").hide();

                     }
                     if (data[0].level == 2) {
                         provinceName = data[0].province;
                         $('#uprovince').combobox('setValue', data[0].province);
                         cityName = data[0].city;
                         $('#ucity').combobox('setValue', data[0].city);
                         $("#dprovince").hide();
                         $("#dcity").hide();
                     }
                     if (data[0].level == 1) {
                         provinceName = data[0].province;
                         $('#uprovince').combobox('setValue', data[0].province);
                         cityName = data[0].city;
                         $('#ucity').combobox('setValue', data[0].city);
                         areaName = data[0].county;
                         $('#ucounty').combobox('setValue', data[0].county);
                         $("#dprovince").hide();
                         $("#dcity").hide();
                         $("#dcounty").hide();
                     }
                 }
             });
         }
         //初始化表格
         function InitGird() {
             $('#tt').datagrid({
                 title: '物品列表', //表格标题
                 url: 'GetStock.ashx', //请求数据的页面
                 sortName: 'mname', //排序字段
                 idField: 'stockid', //标识字段,主键
                 iconCls: '', //标题左边的图标
                 width: '100%', //宽度
                 //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                 nowrap: false, //是否换行，True 就会把数据显示在一行里
                 striped: true, //True 奇偶行使用不同背景色
                 collapsible: false, //可折叠
                 sortOrder: 'desc', //排序类型
                 remoteSort: true, //定义是否从服务器给数据排序
                 fitColumns: true,
                 method: 'post',
                 columns: [[
                     { title: '编号', field: 'mbh', width: 150, sortable: true },
                     { title: '名称', field: 'mname', width: 150 },
                     { title: '型号', field: 'mtype', width: 120 },
                     { title: '库存', field: 'snums', width: 150 },
                     {
                         title: '地址', field: 'uadd', width: 150,
                         formatter: function (value, row, index) {
                             
                             return row.uprovince+row.ucity+row.ucounty+row.uadd;
                             
                         }
                     }
                     
                 ]],
                 toolbar: "#tab_toolbar",
                 queryParams: { "action": "querymy" },
                 pagination: true, //是否开启分页
                 pageNumber: 1, //默认索引页
                 pageSize: 20, //默认一页数据条数
                 rownumbers: true                
             });
         }
         function getQueryParams(queryParams) {
             var uprovince = $("#uprovince").combobox("getValue");
             var ucity = $("#ucity").combobox("getValue");
             var mname = $("#mname").val();
             var otype = document.getElementById("uprovince").value;
             var ucounty = $("#ucounty").combobox("getValue");            
             queryParams.uprovince = uprovince;
             queryParams.ucity = ucity;
             queryParams.mname = mname;
             queryParams.ucounty = ucounty;            
             return queryParams;

         }
         //增加查询参数，重新加载表格  
         function reloadgrid() {

             //查询参数直接添加在queryParams中      
             var queryParams = $('#tt').datagrid('options').queryParams;
             getQueryParams(queryParams);
             $('#tt').datagrid('options').queryParams = queryParams;
             $("#tt").datagrid('reload');

         }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <input name="level" id="level" type="hidden" />
    <table id="tt">
    </table>
    <div id="tab_toolbar" style="padding: 4px;">
        <table cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>
                
                <td style="text-align: left; padding-left: 15px">
                    <div class="fitem" id="dprovince">
                <label>省：</label>
                <input id="uprovince" name="uprovince" class="easyui-combobox" />
            </div>
            <div class="fitem" id="dcity">
                <label>市：</label>
                <input id="ucity" name="ucity" class="easyui-combobox" />
            </div>
            <div class="fitem" id="dcounty">
                <label>县：</label>
                <input id="ucounty" name="ucounty" class="easyui-combobox" />
            </div>  
                    <div class="fitem"> 
          名称:   
           <input id="mname" class="easyui-validatebox"/>   
        
           <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reloadgrid()">查找</a>  
       </div>  
                </td>
            </tr>
        </table>
    </div>   
    

</asp:Content>
